<?php
/* SVN FILE: $Id: cp_skin_items.php 215 2009-09-10 19:07:19Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* ibMarket ACP items html
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 215 $
* @lastrevision $Date: 2009-09-10 19:07:19 +0000 (Thu, 10 Sep 2009) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2009-09-10 19:07:19 +0000 (Thu, 10 Sep 2009) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/skin_cp/cp_skin_items.php $
*/

class cp_skin_items extends output
{

/**
 * Prevent our main destructor being called by this class
 *
 * @access	public
 * @return	void
 */
public function __destruct()
{
}

/**
 * Listing all items stored in the server
 *
 * @access	public
 * @return	string	HTML
 */
public function listAllPHPItems( array $directoryInfo, array $itemsList ) {

$IPBHTML .= <<<EOF
<script type='text/javascript' src='{$this->settings['js_app_url']}addItem.js'></script>
<div class='section_title'>
	<h2>{$this->lang->words['add_item_list_title']}</h2>
</div>
<div id='addItem'>
	<form method='post' action='{$this->settings['base_url']}module=items&amp;section=add&amp;do=add'>
		<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->getSecurityKey()}' />
		<div class='acp-box'>
			<h3>{$this->lang->words['add_item_list_table']}</h3>
			<ul class='acp-form alternate_rows'>
				<li><label class='head'>{$this->lang->words['choose_which_item']}</label></li>

EOF;
foreach($directoryInfo as $directory => $info)
{
	$dropdown = ipsRegistry::getClass('output')->formDropdown('directory['.$directory.']', $itemsList[$directory], -1);
	$IPBHTML .= <<<EOF
				<li>
					<label>
						{$info['title']}

EOF;
	if($info['description'])
	{
		$IPBHTML .= <<<EOF
						<span class="desctext">{$info['description']}</span>

EOF;
	}
	$IPBHTML .= <<<EOF
					</label>
					{$dropdown}
					<script type='text/javascript'>
						ibMarketItemsList.register('directory[{$directory}]');
					</script>
				</li>

EOF;
}
$IPBHTML .= <<<EOF
			</ul>
			<div class='acp-actionbar'>
				<div class='centeraction'>
					<input type='submit' value='{$this->lang->words['add_item_list_button']}' class='button primary'>
				</div>
			</div>
		</div>
	</form>
</div>

EOF;

return $IPBHTML;
}

/**
 * Adding/editing item form
 *
 * @access	public
 * @return	string	HTML
 */
public function itemForm( templateItem $item, array $itemInfo, $nextSection, $nextDo, $title, $submitValue ) {

$description = IPSText::getTextClass('bbcode')->preDisplayParse($item->getDefaultDescription());

$categoryList = array();
foreach(marketRegistry::getCategoryOrder() as $categoryID)
{
	$categoryList[] = array($categoryID,str_repeat("--",marketRegistry::getCategoryDepth($categoryID)).$this->caches['market_category'][$categoryID]['cat_name']);
}

$icons = array();
$defaultIcon = $itemInfo['icon'];
if(!$itemInfo['icon'])
{
	$iconsList = marketRegistry::getIconsList();
	$defaultIcon = $iconsList[array_rand($iconsList)];
	$icons[] = array($defaultIcon,$this->lang->words['select_icon']);
}
foreach(marketRegistry::getIconsList() as $icon)
{
	$icons[] = array($icon, $icon);
}

if ( IPSText::getTextClass('editor')->method == 'rte' )
{
	$_description = IPSText::getTextClass('bbcode')->convertForRTE( $itemInfo['item_description'] );
}
else
{
	$_description = IPSText::getTextClass('bbcode')->preEditParse( $itemInfo['item_description'] );
}

$expireUnits   = array();
$expireUnits[] = array(60, $this->lang->words['minutes']);
$expireUnits[] = array(3600, $this->lang->words['hours']);
$expireUnits[] = array(86400, $this->lang->words['days']);
$expireUnits[] = array(604800, $this->lang->words['weeks']);

$restockWhen   = array();
$restockWhen[] = array(0, $this->lang->words['form_no_restock']);
$restockWhen[] = array(1, $this->lang->words['form_restock_option_1']);
$restockWhen[] = array(2, $this->lang->words['form_restock_option_2']);
$restockWhen[] = array(3, $this->lang->words['form_restock_option_3']);
$restockWhen[] = array(4, $this->lang->words['form_restock_option_4']);

$minute = array();
for($i = 0; $i < 60; $i++)
{
	$minute[$i] = array($i,sprintf($this->lang->words['x_minutes'],$i)." (:".sprintf("%02u",$i).")");
}
$minute[1] = array(1, $this->lang->words['1_minute']." (:01)");

$hours = array();
for($i = 0; $i < 24; $i++)
{
	if($i < 12)
	{
		$hours[$i] = array($i, sprintf($this->lang->words['x_hours'],$i)." (".$i." AM)");
	}
	else
	{
		$hours[$i] = array($i, sprintf($this->lang->words['x_hours'],$i)." (".($i - 12)." PM)");
	}
}
$hours[0]  = array(0,  sprintf($this->lang->words['x_hours'],0)." (12 AM)");
$hours[1]  = array(1,  $this->lang->words['1_hour']." (1 AM)");
$hours[24] = array(24, sprintf($this->lang->words['x_hours'],24)." (".$this->lang->words['every_anyhour'].")");

$days = array();
$days[0] = array(0, sprintf($this->lang->words['x_days'],0)." (".$this->lang->words['dayweek0'].")");
$days[1] = array(1, $this->lang->words['1_day']." (".$this->lang->words['dayweek1'].")");
$days[2] = array(2, sprintf($this->lang->words['x_days'],2)." (".$this->lang->words['dayweek2'].")");
$days[3] = array(3, sprintf($this->lang->words['x_days'],3)." (".$this->lang->words['dayweek3'].")");
$days[4] = array(4, sprintf($this->lang->words['x_days'],4)." (".$this->lang->words['dayweek4'].")");
$days[5] = array(5, sprintf($this->lang->words['x_days'],5)." (".$this->lang->words['dayweek5'].")");
$days[6] = array(6, sprintf($this->lang->words['x_days'],6)." (".$this->lang->words['dayweek6'].")");
$days[7] = array(7, sprintf($this->lang->words['x_days'],7)." (".$this->lang->words['every_anyday'].")");

$this->lang->words['form_restock_time_desc'] = sprintf($this->lang->words['form_restock_time_desc'], gmdate("D, M j, Y h:i A", IPS_UNIX_TIME_NOW));

if($itemInfo['restock'] == 3)
{
	$date = IPSTime::unixstamp_to_human($itemInfo['restock_when']);
	$itemInfo['restock_when'] = sprintf("%02d/%02d/%04d %02d:%02d", $date['month'], $date['day'], $date['year'], $date['hour'] , $date['minute'] );
}

$form['name'] = ipsRegistry::getClass('output')->formInput('item[item_name]', $itemInfo['item_name']);
$form['description'] = IPSText::getTextClass('editor')->showEditor( $_description, 'item_description' );
$form['icon'] = ipsRegistry::getClass('output')->formDropdown('item[icon]', $icons, $itemInfo['icon'],'selectIcon');
$form['category'] = ipsRegistry::getClass('output')->formDropdown('item[category]', $categoryList, $itemInfo['category']);
$form['hide'] = ipsRegistry::getClass('output')->formYesNo('item[hide_item]', $itemInfo['hide_item']);
$form['stock'] = ipsRegistry::getClass('output')->formSimpleInput('item[stock]', $itemInfo['stock']);
$form['price'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('item[base_price]', $itemInfo['base_price'], 10));
$form['resell'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('item[base_resell]', $itemInfo['base_resell'], 10));
$form['allow_resell'] = ipsRegistry::getClass('output')->formYesNo('item[allow_resell]', $itemInfo['allow_resell']);
$form['putback'] = ipsRegistry::getClass('output')->formYesNo('item[resell_putback]', $itemInfo['resell_putback']);
$form['tax'] = ipsRegistry::getClass('output')->formSimpleInput('item[tax]', $itemInfo['tax']);
$form['expire_time'] = ipsRegistry::getClass('output')->formSimpleInput('item[expire_time]', $itemInfo['expire_time']);
$form['expire_unit'] = ipsRegistry::getClass('output')->formDropdown('item[expire_unit]', $expireUnits, $itemInfo['expire_unit']);
$form['limit_inv'] = ipsRegistry::getClass('output')->formSimpleInput('item[inventory_limit]', $itemInfo['inventory_limit']);
$form['limit_buy'] = ipsRegistry::getClass('output')->generateGroupDropdown('item[limit_buy][]', $itemInfo['limit_buy'], true);
$form['limit_use'] = ipsRegistry::getClass('output')->generateGroupDropdown('item[limit_use][]', $itemInfo['limit_use'], true);
$form['restock_howmuch'] = ipsRegistry::getClass('output')->formSimpleInput('item[restock_howmuch]', $itemInfo['restock_howmuch']);
$form['restock_options'] = ipsRegistry::getClass('output')->formDropdown('item[restock]', $restockWhen, $itemInfo['restock']);
$form['restock_when'] = ipsRegistry::getClass('output')->formInput('item[restock_when]', $itemInfo['restock_when']);
$form['restock_minute'] = ipsRegistry::getClass('output')->formDropdown('item[restock_minute]', $minute, $itemInfo['restock_minute']);
$form['restock_hour'] = ipsRegistry::getClass('output')->formDropdown('item[restock_hour]', $hours, $itemInfo['restock_hour']);
$form['restock_day'] = ipsRegistry::getClass('output')->formDropdown('item[restock_day]', $days, $itemInfo['restock_day']);

$IPBHTML .= <<<EOF
<script type='text/javascript' language='javascript'>
	ipb.vars['market_images_url'] = "{$this->settings['market_images_url']}";
	ipb.lang['1_minute'] = "{$this->lang->words['1_minute']}";
	ipb.lang['x_minutes'] = "{$this->lang->words['x_minutes']}";
	ipb.lang['1_hour'] = "{$this->lang->words['1_hour']}";
	ipb.lang['x_hours'] = "{$this->lang->words['x_hours']}";
	ipb.lang['1_day'] = "{$this->lang->words['1_day']}";
	ipb.lang['x_days'] = "{$this->lang->words['x_days']}";
	ipb.lang['dayweek0'] = "{$this->lang->words['dayweek0']}";
	ipb.lang['dayweek1'] = "{$this->lang->words['dayweek1']}";
	ipb.lang['dayweek2'] = "{$this->lang->words['dayweek2']}";
	ipb.lang['dayweek3'] = "{$this->lang->words['dayweek3']}";
	ipb.lang['dayweek4'] = "{$this->lang->words['dayweek4']}";
	ipb.lang['dayweek5'] = "{$this->lang->words['dayweek5']}";
	ipb.lang['dayweek6'] = "{$this->lang->words['dayweek6']}";
	ipb.lang['instantly'] = "{$this->lang->words['instantly']}";
	ipb.lang['bad_time_format'] = "{$this->lang->words['bad_time_format']}";
	ipb.lang['any_day_any_hour_x_minute'] = "{$this->lang->words['_hour_x_minute']}";
	ipb.lang['any_day_at_time'] = "{$this->lang->words['any_day_at_time']}";
	ipb.lang['any_x_at_time'] = "{$this->lang->words['any_x_at_time']}";
	ipb.lang['every_day_every_hour_x_minute'] = "{$this->lang->words['every_day_every_hour_x_minute']}";
	ipb.lang['every_day_at_time'] = "{$this->lang->words['every_day_at_time']}";
	ipb.lang['every_x_at_time'] = "{$this->lang->words['every_x_at_time']}";
	ipb.lang['form_stock_reaches'] = "{$this->lang->words['form_stock_reaches']}";
	ipb.lang['form_stock_reaches_desc'] = "{$this->lang->words['form_stock_reaches_desc']}";
	ipb.lang['form_last_stock'] = "{$this->lang->words['form_last_stock']}";
	ipb.lang['form_last_stock_desc'] = "{$this->lang->words['form_last_stock_desc']}";
	ipb.lang['form_restock_time_1'] = "{$this->lang->words['form_restock_time_1']}";
	ipb.lang['form_restock_time_2'] = "{$this->lang->words['form_restock_time_2']}";
	ipb.lang['form_restock_time_3'] = "{$this->lang->words['form_restock_time_3']}";
	ipb.lang['form_restock_time_desc'] = "{$this->lang->words['form_restock_time_desc']}";
	ipb.lang['restock_message_1'] = "{$this->lang->words['restock_message_1']}";
	ipb.lang['restock_message_2'] = "{$this->lang->words['restock_message_2']}";
	ipb.lang['restock_message_3'] = "{$this->lang->words['restock_message_3']}";
	ipb.lang['restock_message_4'] = "{$this->lang->words['restock_message_4']}";
	ipb.lang['restock_message_3_second'] = "{$this->lang->words['restock_message_3_second']}";
	ipb.lang['restock_no_restock'] = "{$this->lang->words['restock_no_restock']}";
	ipb.lang['restock_bad_input'] = "{$this->lang->words['restock_bad_input']}";
	ipb.lang['restock_instantly'] = "{$this->lang->words['restock_instantly']}";
</script>
<script type='text/javascript' src='{$this->settings['js_app_url']}icons.js'></script>
<script type='text/javascript' src='{$this->settings['js_app_url']}itemForm.js'></script>
<div class='section_title'>
	<h2>{$title}</h2>
</div>

<div id='itemFormPage'>
	<form method='post' enctype="multipart/form-data" action='{$this->settings['base_url']}module=items&amp;section={$nextSection}&amp;do={$nextDo}' id='itemForm'>
		<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->getSecurityKey()}' />
		<input type='hidden' name='item_id' value='{$itemInfo['item_id']}' />
		<input type='hidden' name='item[filename]' value='{$itemInfo['filename']}' />
		<div class='acp-box'>
			<h3>{$title}</h3>
			<ul class='acp-form alternate_rows'>
				<li><label class='head'>{$this->lang->words['form_main_info']}</label></li>
				<li>
					<label>{$this->lang->words['form_server_location']}</label>
					{$itemInfo['filename']}
				</li>
				<li>
					<label>{$this->lang->words['form_default_info']}</label>
					<div style='display: inline-block'>
						<strong>{$item->getDefaultName()}</strong>
						<br />
						{$description}
					</div>
				</li>
				<li>
					<label>{$this->lang->words['form_item_name']}</label>
					{$form['name']}
				</li>
				<li>
					<label>{$this->lang->words['form_description']}</label>
					<br />
					{$form['description']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_category']}
						<span class="desctext">{$this->lang->words['form_category_desc']}</span>
					</label>
					{$form['category']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_info']}
						<span class="desctext">{$this->lang->words['form_info_desc']}</span>
					</label>
					{$form['icon']} <img src='{$this->settings['market_images_url']}/icons/{$defaultIcon}' alt='{$this->lang->words['icon_alt']}' id='selectIcon_icon' />
				</li>
				<li>
					<label>
						{$this->lang->words['form_hide']}
						<span class="desctext">{$this->lang->words['form_hide_desc']}</span>
					</label>
					{$form['hide']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_stock']}
						<span class="desctext">{$this->lang->words['form_stock_desc']}</span>
					</label>
					{$form['stock']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_price']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['form_price_desc']}</span>
					</label>
					{$form['price']}
				</li>
				<li>
					<label>{$this->lang->words['form_allow_resold']}</label>
					{$form['allow_resell']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_resell']}
						<span class="desctext">{$this->lang->words['form_resell_desc']}</span>
					</label>
					{$form['resell']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_putback']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['form_putback_desc']}</span>
					</label>
					{$form['putback']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_tax']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['form_tax_desc']}</span>
					</label>
					{$form['tax']}%
				</li>
				<li>
					<label>
						{$this->lang->words['form_expire']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['form_expire_desc']}</span>
					</label>
					{$form['expire_time']}{$form['expire_unit']}
				</li>
				<li><label class='head'>{$this->lang->words['form_limiters']}</label></li>
				<li>
					<label>
						{$this->lang->words['form_limit_inventory']}
						<span class="desctext">{$this->lang->words['form_limit_inventory_desc']}</span>
					</label>
					{$form['limit_inv']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_limit_buy']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['form_limit_buy_desc']}</span>
					</label>
					{$form['limit_buy']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_limit_use']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['form_limit_use_desc']}</span>
					</label>
					{$form['limit_use']}
				</li>
				<li><label class='head'><input id="restockInfo" class="textinput" type="text" size="1" style="float:right; width:60%; min-width: 500px; margin-right: 5px" />{$this->lang->words['form_restock_options']}</label></li>
				<li>
					<label>
						{$this->lang->words['form_restock_howmuch']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['form_restock_howmuch_desc']}</span>
					</label>
					{$form['restock_howmuch']}
				</li>
				<li>
					<label>
						{$this->lang->words['form_restock_when']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['form_restock_when_desc']}</span>
					</label>
					{$form['restock_options']}
				</li>
				<li id='li_restock_when'>
					<label>
						<span style='white-space: nowrap' id='restock_when_ques'></span>
						<span class="desctext" style='white-space: nowrap' id='restock_when_desc'></span>
					</label>
					{$form['restock_when']}<input id="restockButton" type="button" value="{$this->lang->words['form_current_time']}" />
				</li>
				<li id='li_restock_time'>
					<label>
						<span id='restock_time_ques'></span>
						<span class="desctext" style='white-space: nowrap' id='restock_time_desc'></span>
					</label>
					<div style='display: inline-block'>
						{$form['restock_day']}
						<br />
						{$form['restock_hour']}
						<br />
						{$form['restock_minute']}
					</div>
				</li>
EOF;
if($form = $item->adminForm())
{
	$IPBHTML .= <<<EOF
				<li><label class='head'>{$this->lang->words['form_extra_settings']}</label></li>
EOF;
	$IPBHTML .= $form;
}
$IPBHTML .= <<<EOF
			</ul>
			<div class='acp-actionbar'>
				<div class='centeraction'>
					<input type='submit' value='{$submitValue}' class='button primary'>
				</div>
			</div>
		</div>
	</form>
</div>
<script type='text/javascript' language='javascript'>
	ibMarketIcons.register('selectIcon');
</script>
EOF;

return $IPBHTML;
}

/**
 * Listing all the items
 *
 * @access	public
 * @return	string	HTML
 */
public function listItems( array $items ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['list_items_title']}</h2>
</div>

<div id='catgories'>
	<div class='acp-box'>
		<h3 style='height:24px'>
			<div style='float:right'>
				<input type="button" value="{$this->lang->words['toggle_quick_edit']}" onclick="window.location.href='{$this->settings['base_url']}module=items&section=quick_edit&category={$this->request['category']}&showAll={$this->request['showAll']}'" />
			</div>
			{$this->lang->words['list_items_table']}
		</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['icon']}</th>
				<th style=''>{$this->lang->words['category']}</th>
				<th style='white-space:nowrap'>{$this->lang->words['name_description']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['options']}</th>
			</tr>
EOF;
foreach($items as $item)
{
	$item['description'] = IPSText::getTextClass('bbcode')->preDisplayParse(marketRegistry::getItem($item)->parseStoreDescription());
	$IPBHTML .= <<<EOF
			<tr>
				<td><img src='{$this->settings['market_images_url']}/icons/{$item['icon']}' alt='{$this->lang->words['id']}{$item['item_id']}' /></td>
				<td>{$this->caches['market_category'][$item['category']]['cat_name']}</td>
				<td>
					<strong>{$item['item_name']}</strong>
					<br />
					{$item['description']}
				</td>
				<td>
					<img class='ipbmenu' id="menum-{$item['item_id']}" src='{$this->settings['skin_acp_url']}/_newimages/menu_open.png' alt='{$this->lang->words['frm_options']}' /> &nbsp;
					<ul class='acp-menu' id='menum-{$item['item_id']}_menucontent'>
						<li class='icon edit'><a href='{$this->settings['base_url']}module=items&amp;section=edit&amp;item_id={$item['item_id']}'>{$this->lang->words['edit_item']}</a></li>
						<li class='icon delete'><a href='{$this->settings['base_url']}module=items&amp;section=delete&amp;item_id={$item['item_id']}'>{$this->lang->words['delete_item']}</a></li>
					</ul>
				</td>
			</tr>
EOF;
}

$IPBHTML .= <<<EOF
		</table>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * Quick editing the items
 *
 * @access	public
 * @return	string	HTML
 */
public function quickEditForm( array $items ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['list_items_title']}</h2>
</div>

<div id='catgories'>
	<form method='post' action='{$this->settings['base_url']}module=items&amp;section=quick_edit&amp;category={$this->request['category']}&amp;showAll={$this->request['showAll']}' id='itemForm'>
		<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->getSecurityKey()}' />
		<div class='acp-box'>
			<h3 style='height:24px'>
				<div style='float:right'>
					<input type="button" value="{$this->lang->words['toggle_quick_edit']}" onclick="window.location.href='{$this->settings['base_url']}module=items&section=view&category={$this->request['category']}&showAll={$this->request['showAll']}'" />
				</div>
				{$this->lang->words['list_items_table']}
			</h3>
			<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
				<tr>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['icon']}</th>
					<th style=''>{$this->lang->words['category']}</th>
					<th style='white-space:nowrap'>{$this->lang->words['name_description']}</th>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['stock']}</th>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['price']}</th>
				</tr>
EOF;
foreach($items as $item)
{
	$item['description'] = IPSText::getTextClass('bbcode')->preDisplayParse(marketRegistry::getItem($item)->parseStoreDescription());
	$form['stock'] = ipsRegistry::getClass('output')->formSimpleInput('item['.$item['item_id'].'][stock]', $item['stock'] == -1 ? 'infinite' : $item['stock']);
	$form['price'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('item['.$item['item_id'].'][base_price]', $item['base_price'], 10));
	
	$IPBHTML .= <<<EOF
				<tr>
					<td><img src='{$this->settings['market_images_url']}/icons/{$item['icon']}' alt='{$this->lang->words['id']}{$item['item_id']}' /></td>
					<td>{$this->caches['market_category'][$item['category']]['cat_name']}</td>
					<td>
						<strong>{$item['item_name']}</strong>
						<br />
						{$item['description']}
					</td>
					<td>{$form['stock']}</td>
					<td style='white-space:nowrap'>{$form['price']}</td>
				</tr>
EOF;
}

$IPBHTML .= <<<EOF
			</table>
		</div>
			<div class='acp-actionbar'>
				<div class='centeraction'>
					<input type='submit' value='{$this->lang->words['save']}' class='button primary'>
				</div>
			</div>
	</form>
</div>

EOF;

return $IPBHTML;
}

/**
 * Adding/editing item form
 *
 * @access	public
 * @return	string	HTML
 */
public function deleteItemForm( array $itemInfo ) {

$deleteOption   = array();
$deleteOption[] = array(0, $this->lang->words['delete_item_option_0']);
$deleteOption[] = array(1, $this->lang->words['delete_item_option_1']);
$deleteOption[] = array(2, $this->lang->words['delete_item_option_2']);
$deleteOption[] = array(3, $this->lang->words['delete_item_option_3']);

$form['inventory'] = ipsRegistry::getClass('output')->formDropdown('delete_option', $deleteOption);

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['delete_item_title']}</h2>
</div>

<div id='deleteItemForm'>
	<form method='post' action='{$this->settings['base_url']}module=items&amp;section=delete&amp;do=delete' id='itemForm'>
		<input type='hidden' name='item_id' value='{$itemInfo['item_id']}' />
		<div class='acp-box'>
			<h3>{$this->lang->words['delete_item_table']}</h3>
			<ul class='acp-form alternate_rows'>
				<li>
					<label>{$this->lang->words['delete_item_name']}</label>
					{$itemInfo['item_name']}
				</li>
				<li>
					<label>{$this->lang->words['delete_item_inventory']}</label>
					{$form['inventory']}
				</li>
			</ul>
			<div class='acp-actionbar'>
				<div class='centeraction'>
					<input type='submit' value='{$this->lang->words['delete_item_button']}' class='button primary'>
				</div>
			</div>
		</div>
	</form>
</div>
EOF;

return $IPBHTML;
}

/**
 * Listing all items that has file edits
 *
 * @access	public
 * @return	string	HTML
 */
public function listItemFileEdit( array $directoryInfo, array $itemsList ) {

$IPBHTML .= <<<EOF
<script type='text/javascript' src='{$this->settings['js_app_url']}addItem.js'></script>
<div class='section_title'>
	<h2>{$this->lang->words['file_edits_title']}</h2>
</div>
<div id='addItem'>
	<form method='post' action='{$this->settings['base_url']}module=items&amp;section=fileedits&amp;do=edits'>
		<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->getSecurityKey()}' />
		<div class='acp-box'>
			<h3>{$this->lang->words['file_edits_table']}</h3>
			<ul class='acp-form alternate_rows'>
				<li><label class='head'>{$this->lang->words['choose_which_item']}</label></li>

EOF;
foreach($directoryInfo as $directory => $info)
{
	if(!is_array($itemsList[$directory]) || count($itemsList[$directory]) <= 1)
	{
		continue;
	}
	
	$dropdown = ipsRegistry::getClass('output')->formDropdown('directory['.$directory.']', $itemsList[$directory], -1);
	$IPBHTML .= <<<EOF
				<li>
					<label>
						{$info['title']}

EOF;
	if($info['description'])
	{
		$IPBHTML .= <<<EOF
						<span class="desctext">{$info['description']}</span>

EOF;
	}
	$IPBHTML .= <<<EOF
					</label>
					{$dropdown}
					<script type='text/javascript'>
						ibMarketItemsList.register('directory[{$directory}]');
					</script>
				</li>

EOF;
}
$IPBHTML .= <<<EOF
			</ul>
			<div class='acp-actionbar'>
				<div class='centeraction'>
					<input type='submit' value='{$this->lang->words['file_edits_button']}' class='button primary'>
				</div>
			</div>
		</div>
	</form>
</div>

EOF;

return $IPBHTML;
}

/**
 * Showing the item file edits
 *
 * @access	public
 * @return	string	HTML
 */
public function itemFileEdit( templateItem $item ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['view_file_edits_title']}</h2>
</div>

EOF;
$IPBHTML .= $item->adminViewFileEdits();

return $IPBHTML;
}

}